package com.butterfly.hotkey.client.core.service;


import com.butterfly.hotkey.client.core.collector.IKeyCollector;
import com.butterfly.hotkey.core.model.HotKeyModel;
import com.butterfly.hotkey.core.model.KeyCountModel;
import com.butterfly.hotkey.core.model.KeyModel;

/**
 * @author butterfly
 * @since 2024/11/1
 */
public class KeyCollectorService {

    /**
     * key 访问的收集器
     */
    private final IKeyCollector<HotKeyModel, HotKeyModel> keyAccessCollector;

    /**
     * key 计数收集器
     */
    private final IKeyCollector<KeyModel, KeyCountModel> keySummaryCollector;

    public KeyCollectorService(IKeyCollector<KeyModel, KeyCountModel> keySummaryCollector,
                               IKeyCollector<HotKeyModel, HotKeyModel> keyAccessCollector) {
        this.keySummaryCollector = keySummaryCollector;
        this.keyAccessCollector = keyAccessCollector;
    }

    public void access(HotKeyModel hotKeyModel) {
        keyAccessCollector.collect(hotKeyModel);
    }

    public void collect(KeyModel hotKeyModel) {
        keySummaryCollector.collect(hotKeyModel);
    }

    public IKeyCollector<HotKeyModel, HotKeyModel> getKeyAccessCollector() {
        return keyAccessCollector;
    }

    public IKeyCollector<KeyModel, KeyCountModel> getKeySummaryCollector() {
        return keySummaryCollector;
    }

}
